package com.zhoust.fastdome.business.controller;

import com.zhoust.fastdome.annnotation.LogAutoRecord;
import com.zhoust.fastdome.annnotation.LogAutoRecordTestClass;
import com.zhoust.fastdome.annnotation.LogAutoRecordTestSource;
import com.zhoust.fastdome.business.dao.UserMapper;
import com.zhoust.fastdome.business.dto.UserRequestDTO;
import com.zhoust.fastdome.business.service.UserService;
import com.zhoust.fastdome.common.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhoust
 */
@Slf4j
@RestController
public class UserTestLogController {

    private final UserMapper userMapper;
    private final UserService userService;
    public UserTestLogController(UserMapper userMapper, UserService userService) {
        this.userMapper = userMapper;
        this.userService = userService;
    }
    @GetMapping("/getUserByParameter")
    @LogAutoRecord(methodDesc = "根据用户ID查询用户信息")
    public CommonResponse getUserById(String id){
        String userById = userService.getUserById(id);
        return CommonResponse.succeed(userById);
    }
    @GetMapping("/getUserByCommon")
    @LogAutoRecord(methodDesc = "根据统一请求查询用户信息")
    public CommonResponse getUserByCommonRequest(@RequestBody UserRequestDTO userRequestDTO){
        String userById = userService.getUserById(userRequestDTO.getUserId());
        return CommonResponse.succeed(userById);
    }
    @GetMapping("/getUserByCommonTestSource")
    @LogAutoRecordTestSource(methodDesc = "根据统一请求查询用户信息,测试注解属性source")
    public CommonResponse getUserByCommonTestSource(@RequestBody UserRequestDTO userRequestDTO){
        String userById = userService.getUserById(userRequestDTO.getUserId());
        return CommonResponse.succeed(userById);
    }
    @GetMapping("/getUserByCommonTestClass")
    @LogAutoRecordTestClass(methodDesc = "根据统一请求查询用户信息,测试注解属性Class")
    public CommonResponse getUserByCommonTestClass(@RequestBody UserRequestDTO userRequestDTO){
        String userById = userService.getUserById(userRequestDTO.getUserId());
        return CommonResponse.succeed(userById);
    }
}
